package com.louis.buddhist.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.louis.buddhist.R;
import com.louis.buddhist.data.entity.CollectEntity;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by fenglei on 2018/4/11.
 */

public class CollectDialogAdapter extends BaseQuickAdapter<CollectEntity, BaseViewHolder> {

    private Context mContext;
    private SimpleDateFormat sdf;

    public CollectDialogAdapter(Context context, int layoutResId, @Nullable List<CollectEntity> data) {
        super(layoutResId, data);
        mContext = context;
        sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    }

    @Override
    protected void convert(BaseViewHolder helper, CollectEntity item) {

        ImageView pic = helper.getView(R.id.iv_pic);
        Glide.with(mContext).load(item.getCover()).into(pic);

        helper.setText(R.id.tv_name, item.getName()).setText(R.id.tv_page, "第"+item.getPage()+"頁").setText(R.id.tv_date, sdf.format(item.getDate()));

        helper.addOnClickListener(R.id.tv_read);
        helper.addOnClickListener(R.id.tv_del);
    }
}
